{	Problem: http://codechef.com/problems/PRIMES2/
 	Verdict: Accepted
}
var i,j,cnt,n,k:longint; p:array[0..1000010] of boolean; a:array[0..1010] of longint;
		f:boolean;
begin
fillchar(p,sizeof(p),true);
cnt:=0;
for i:=2 to 1000 do begin
	if p[i] then begin
		j:=i*i;
		while j<=1000000 do begin
			p[j]:=false;
      inc(j,i);
		end;
		inc(cnt);
		a[cnt]:=i;
	end;
end;
read(n);
while n<>0 do begin
	f:=true;
	for i:=1 to cnt do begin
		if not f then break;
		if a[i]*a[i]*a[i]<n then begin
			for j:=1 to cnt do begin
				k:=n-a[i]*a[i]*a[i]-a[j]*a[j];
				if k>0 then 
					if p[k] then begin
						writeln(k,' ',a[j],' ',a[i]);
						f:=false;
						break;
					end;
			end;
		end else break;
	end;
	if f then writeln('0 0 0');
	read(n);
end;
end.